package com.umeox.ota.data.db;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import java.util.List;

/**
 * @author fighter_lee
 * @date 2018/7/25
 */
@Dao
public interface ClientDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(ClientEntity clientEntity);

    @Query("SELECT * FROM Client")
    List<ClientEntity> getAll();

    @Delete
    void delete(ClientEntity entity);

    @Query("SELECT * FROM Client Where _id = 0")
    ClientEntity queryClient();

    @Query("SELECT Mid FROM Client where _id = 0")
    String queryMid();

    @Query("UPDATE Client SET Mid = :mid where _id = 0")
    void setMid(String mid);

    @Query("UPDATE Client SET DownloadTime = :downloadTime where _id = 0")
    void setDownloadTime(int downloadTime);

    @Query("SELECT DownloadTime FROM Client where _id = 0")
    int queryDownloadTime();

    @Query("UPDATE Client SET ObtainMidTime = :obtainMidTime where _id = 0")
    void setObtainMidTime(int obtainMidTime);

    @Query("SELECT ObtainMidTime FROM Client where _id = 0")
    int queryObtainMidTime();
}
